//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package net.mingsoft.basic.util;

import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MapCacheUtil {
    private static Cache<String, Object> cache = CacheUtil.newLFUCache(0);
    private static final Logger LOGGER = LoggerFactory.getLogger(MapCacheUtil.class);

    public MapCacheUtil() {
    }

    public static void put(String key, Object object, boolean cover) {
        if (cache.get(key) != null) {
            LOGGER.info("key: {} 的对象已存在", key);
            if (cover) {
                cache.put(key, object);
                LOGGER.info("已覆盖key: {} 的对象", key);
            }
        } else {
            cache.put(key, object);
        }

    }

    public static void put(String key, Object object) {
        put(key, object, true);
    }

    public static void remove(String key) {
        cache.remove(key);
    }

    public static Object get(String key) {
        return cache.get(key);
    }
}
